package com.abcdefg.lotterysystem.common.exception;

import com.abcdefg.lotterysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

// @Data 生成自己的 equals  hashcode
//加入@EqualsAndHashCode(callSuper = true)根据父类属性生成hashcode（）方法和equals（）方法
@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException {

    private Integer code;
    private String message;

    public ServiceException(){

    }

    public ServiceException(Integer code, String message){
        this.code = code;
        this.message = message;
    }

    public ServiceException(ErrorCode errorCode){
        this.code=errorCode.getCode();
        this.message=errorCode.getMsg();
    }

}
